

// Variables that are used on both client and server

SWEP.Author			= "Valve"
SWEP.Contact		= "n/a"
SWEP.Purpose		= "Shooting Rockets"
SWEP.Instructions	= "Primary= Shoot Rockets"

SWEP.ViewModelFOV	= 54
SWEP.ViewModelFlip	= false
SWEP.ViewModel		= "models/weapons/v_mll.mdl"
SWEP.WorldModel		= "models/weapons/w_rocket_launcher.mdl"
SWEP.AnimPrefix		= "rpg"
SWEP.Category	        = "HL2 Beta Sweps"

SWEP.Spawnable			= false
SWEP.AdminSpawnable		= true

SWEP.Primary.ClipSize		= 1					// Size of a clip
SWEP.Primary.DefaultClip	= 6				// Default number of bullets in a clip
SWEP.Primary.Automatic		= false			// Automatic/Semi Auto
SWEP.Primary.Ammo			= "CombineCannon"

SWEP.Secondary.ClipSize		= 1					// Size of a clip
SWEP.Secondary.DefaultClip	= 1				// Default number of bullets in a clip
SWEP.Secondary.Automatic	= false				// Automatic/Semi Auto
SWEP.Secondary.Ammo			= ""

function SWEP:Initialize()

end

function SWEP:Precache()
	util.PrecacheSound("NPC_Helicopter.FireRocket")
	util.PrecacheSound("Buttons.snd14")
end
 
function SWEP:Deploy()
	self.Weapon:SendWeaponAnim( ACT_VM_DEPLOY )	
end

function SWEP:PrimaryAttack()
	local class = self:GetOwner():GetEyeTraceNoCursor().Entity:GetClass();
	if (class == "npc_manhack" or class == "npc_strider" or class == "npc_combinegunship" or
		class == "npc_combinedropship" or class == "npc_helicopter") then 
		self.Weapon:SetNextPrimaryFire( CurTime() + 1.5 )
		self.Weapon:EmitSound( NPC_Helicopter.FireRocket )
		self:SetClip1( self:Clip1() -1 )
		self:FireRocket()	
		self.Weapon:TakePrimaryAmmo( 1 )
		self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
		self.Owner:SetAnimation( PLAYER_ATTACK1 )
		self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
	                else return end

end


function SWEP:FireRocket()
	local aim = self.Owner:GetAimVector()
	local side = aim:Cross(Vector(0,0,1))
	local up = side:Cross(aim)
	local pos = self.Owner:GetShootPos() +  aim * 24 + side * 8 + up * -1	--offsets the rocket so it spawns from the muzzle (hopefully)
	local rocket = ents.Create("bazooka_round")
		if !rocket:IsValid() then return false end
		rocket:SetAngles(aim:Angle())
		rocket:SetPos(pos)
	rocket:SetOwner(self.Owner)
	rocket:Spawn()
	rocket:Activate()
	rocket:SetVelocity(rocket:GetForward()*3000)
end

function SWEP:SecondaryAttack()

end

function SWEP:Reload()
	if self:DefaultReload( ACT_VM_RELOAD ) then 
		self:EmitSound(Sound("weapons/rpg/rpg_reload.wav")) 
	        end

        end